import huck

class MainPage(huck.RequestHandler):
  def get(self):
    self.response.out.write('<html><body>')
    self.response.out.write('<p>Why not <a href="/hello/world/">click here</a>.')
    self.response.out.write('</body></html>')

class HelloPage(huck.RequestHandler):
  def get(self, node1, node2):
    self.response.out.write('<html><body>')
    self.response.out.write('<p>%s %s</p>' % (node1, node2))
    self.response.out.write('</body></html>')

class NotFoundPage(huck.RequestHandler):
  def get(self):
    self.response.set_status(404)
    self.response.out.write('<html><body>')
    self.response.out.write('Not Found')
    self.response.out.write('</body></html>')

# Setup urls
url_mapping = [
               ('/', MainPage),
               ('^/([a-zA-Z0-9-_]*)/([a-zA-Z0-9-_]*)/$', HelloPage),
               ('.*', NotFoundPage),
              ]
application = huck.Application(url_mapping, debug=True)

if __name__ == '__main__':
  huck.run_dev('', 8080, application)
